//
//  TimeTableViewCell.swift
//  DriverSchoolAPP
//
//  Created by Logel on 2017/5/11.
//  Copyright © 2017年 Logel. All rights reserved.
//

import UIKit

class TimeTableViewCell: UITableViewCell {
    @IBOutlet weak var okBtn: UIButton!
    @IBOutlet weak var courseNameLbl: UILabel!
    @IBOutlet weak var classTimeLbl: UILabel!
    @IBOutlet weak var priceLbl: UILabel!

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        okBtn.layer.cornerRadius = 5
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    var mc:MyCourse!{
        didSet{
            courseNameLbl.text = mc.courseName
            
            switch mc.price {
            case "":
                priceLbl.isHidden = true
            default:
                priceLbl.isHidden = false
                priceLbl.text = "￥\(mc.price)"
            }
            
            let dateFormatter = DateFormatter()
            dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
            let d = dateFormatter.date(from: mc.classTime)
            
            let dateFormatter2 = DateFormatter()
            dateFormatter2.dateFormat = "yyyy-MM-dd"
            let ymd =  dateFormatter2.string(from: d!)
            classTimeLbl.text  = "\(ymd) \(mc.startTime)-\(mc.endTime)"
            
        
            switch mc.status {
            case "complet":
                okBtn.setTitle("未上课", for: .normal)
            default:
                okBtn.setTitle("已完成", for: .normal)
            }
        }
        
    }

}
